/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package de.hsmannheim.pepa.patientenportal.apanwep.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import de.hsmannheim.pepa.patientenportal.apanwep.model.contact;
import de.hsmannheim.pepa.patientenportal.apanwep.model.contactModel;
import de.hsmannheim.pepa.patientenportal.apanwep.model.contactSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the contact service. Represents a row in the &quot;contact&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link de.hsmannheim.pepa.patientenportal.apanwep.model.contactModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link contactImpl}.
 * </p>
 *
 * @author Cedric Nana
 * @see contactImpl
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.contact
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.contactModel
 * @generated
 */
@JSON(strict = true)
public class contactModelImpl extends BaseModelImpl<contact>
	implements contactModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a contact model instance should use the {@link de.hsmannheim.pepa.patientenportal.apanwep.model.contact} interface instead.
	 */
	public static final String TABLE_NAME = "contact";
	public static final Object[][] TABLE_COLUMNS = {
			{ "message_id", Types.BIGINT },
			{ "user_id", Types.BIGINT },
			{ "datetime", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table contact (message_id LONG not null primary key,user_id LONG,datetime VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table contact";
	public static final String ORDER_BY_JPQL = " ORDER BY contact.message_id ASC";
	public static final String ORDER_BY_SQL = " ORDER BY contact.message_id ASC";
	public static final String DATA_SOURCE = "apanwepDataSource";
	public static final String SESSION_FACTORY = "apanwepSessionFactory";
	public static final String TX_MANAGER = "apanwepTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.contact"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.contact"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static contact toModel(contactSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		contact model = new contactImpl();

		model.setMessage_id(soapModel.getMessage_id());
		model.setUser_id(soapModel.getUser_id());
		model.setDatetime(soapModel.getDatetime());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<contact> toModels(contactSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<contact> models = new ArrayList<contact>(soapModels.length);

		for (contactSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.de.hsmannheim.pepa.patientenportal.apanwep.model.contact"));

	public contactModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _message_id;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setMessage_id(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _message_id;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return contact.class;
	}

	@Override
	public String getModelClassName() {
		return contact.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("message_id", getMessage_id());
		attributes.put("user_id", getUser_id());
		attributes.put("datetime", getDatetime());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long message_id = (Long)attributes.get("message_id");

		if (message_id != null) {
			setMessage_id(message_id);
		}

		Long user_id = (Long)attributes.get("user_id");

		if (user_id != null) {
			setUser_id(user_id);
		}

		String datetime = (String)attributes.get("datetime");

		if (datetime != null) {
			setDatetime(datetime);
		}
	}

	@JSON
	@Override
	public long getMessage_id() {
		return _message_id;
	}

	@Override
	public void setMessage_id(long message_id) {
		_message_id = message_id;
	}

	@JSON
	@Override
	public long getUser_id() {
		return _user_id;
	}

	@Override
	public void setUser_id(long user_id) {
		_user_id = user_id;
	}

	@JSON
	@Override
	public String getDatetime() {
		if (_datetime == null) {
			return StringPool.BLANK;
		}
		else {
			return _datetime;
		}
	}

	@Override
	public void setDatetime(String datetime) {
		_datetime = datetime;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			contact.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public contact toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (contact)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		contactImpl contactImpl = new contactImpl();

		contactImpl.setMessage_id(getMessage_id());
		contactImpl.setUser_id(getUser_id());
		contactImpl.setDatetime(getDatetime());

		contactImpl.resetOriginalValues();

		return contactImpl;
	}

	@Override
	public int compareTo(contact contact) {
		long primaryKey = contact.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof contact)) {
			return false;
		}

		contact contact = (contact)obj;

		long primaryKey = contact.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<contact> toCacheModel() {
		contactCacheModel contactCacheModel = new contactCacheModel();

		contactCacheModel.message_id = getMessage_id();

		contactCacheModel.user_id = getUser_id();

		contactCacheModel.datetime = getDatetime();

		String datetime = contactCacheModel.datetime;

		if ((datetime != null) && (datetime.length() == 0)) {
			contactCacheModel.datetime = null;
		}

		return contactCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{message_id=");
		sb.append(getMessage_id());
		sb.append(", user_id=");
		sb.append(getUser_id());
		sb.append(", datetime=");
		sb.append(getDatetime());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("de.hsmannheim.pepa.patientenportal.apanwep.model.contact");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>message_id</column-name><column-value><![CDATA[");
		sb.append(getMessage_id());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>user_id</column-name><column-value><![CDATA[");
		sb.append(getUser_id());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>datetime</column-name><column-value><![CDATA[");
		sb.append(getDatetime());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = contact.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			contact.class
		};
	private long _message_id;
	private long _user_id;
	private String _datetime;
	private contact _escapedModel;
}